package context;

import bean.UserInfo;
import io.netty.channel.Channel;
import message.Message;

/**
 * @author wb_zhulinzhong
 * @date 2021-04-14 17:20:09
 */
public class ComClientContext {

    public static UserInfo userInfo;

    private Channel clientChannel;


    private static final ComClientContext comContext = new ComClientContext();

    private ComClientContext(){ }

    public static ComClientContext comContext(){
        return comContext;
    }

    public Channel getClientChannel() {
        return clientChannel;
    }


    public void setClientChannel(Channel clientChannel) {
        this.clientChannel = clientChannel;
    }

    /**
     * 客户端发送消息
     * @param message
     */
    public void clientSendMessageToServer(Message message){
        this.clientChannel.writeAndFlush(message);
    }

    public static boolean isLogin() {
        return userInfo != null && userInfo.isLogin();
    }
}
